package com.jml.AOP004.责任链通知005;


import com.jml.AOP004.责任链通知005.interceptor.MethodInterceptor;
import com.jml.AOP004.责任链通知005.interceptor.impl.AfterMethodInterceptor;
import com.jml.AOP004.责任链通知005.interceptor.impl.AroundMethodInterceptor;
import com.jml.AOP004.责任链通知005.interceptor.impl.BeforMethodInterceptor;
import com.jml.AOP004.责任链通知005.invocation.impl.DefaultMethodInvacation;
import com.jml.AOP004.责任链通知005.service.UserService;
import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * @author:jml
 * @date: 2019/9/26 10:02
 * @description：
 */
public class MainTest {
	
	public static void main(String[] args) throws Exception {
		ArrayList<MethodInterceptor> methodInterceptors = new ArrayList<MethodInterceptor>();
		methodInterceptors.add(new AroundMethodInterceptor());
		methodInterceptors.add(new BeforMethodInterceptor());
		methodInterceptors.add(new AfterMethodInterceptor());
		
		// 2.创建我们的目标方法
		UserService userService = new UserService();
		Method method = UserService.class.getMethod("login", String.class, Integer.class);
		Object[] objects = {"jml", 123};
		
		DefaultMethodInvacation defaultMethodInvacation = new DefaultMethodInvacation(
				methodInterceptors, userService, method, objects);
		defaultMethodInvacation.process();
		
	}
}
